﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net.Sockets;
using System.Net;
using System.Text;

namespace WeiXinPF.Web.weixin.pano360.Templates.Normal
{
    /// <summary>
    /// scenic 的摘要说明
    /// </summary>
    public class scenic : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            
            string result = "";
            string action = context.Request["action"];
            switch (action)
            { 
                case  "geturl":
                result = gethttpvalues(context.Request["url"]);
                break;
                default:
                break;
            }
            context.Response.Write(result);
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }

        public string gethttpvalues(string url)
        {
            WebClient MyWebClient = new WebClient();
            MyWebClient.Credentials = CredentialCache.DefaultCredentials;//获取或设置用于向Internet资源的请求进行身份验证的网络凭据
            Byte[] pageData = MyWebClient.DownloadData(url); //从指定网站下载数据
            string pageHtml = Encoding.UTF8.GetString(pageData);  //如果获取网站页面采用的是GB2312，则使用这句      
            //pageHtml = pageHtml.Replace("\n    ", "").Replace("    ","").Replace("\"", "'");    
            return pageHtml;
        }
    }
}